package com.yl.ydk.presenter.impl

import android.content.Context
import com.yl.ydk.R
import com.yl.ydk.api.Api
import com.yl.ydk.base.BasePresenter
import com.yl.ydk.bean.GoodsDetailBean
import com.yl.ydk.bean.LiveDetailBean
import com.yl.ydk.presenter.contract.TXCloudVideoActivityContract
import com.yl.ydk.presenter.contract.TestPapersContract
import rx.Observer
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers

class TXCloudVideoActivityImpl  : BasePresenter<TXCloudVideoActivityContract.View>(),
    TXCloudVideoActivityContract.Presenter<TXCloudVideoActivityContract.View> {


    override fun getLiveDetail(context: Context, vararg s: String) {
        addSubscrebe(
            Api.getInstance()?.getLiveDetail(*s)
                ?.observeOn(AndroidSchedulers.mainThread())
                ?.subscribeOn(Schedulers.io())
                ?.unsubscribeOn(Schedulers.io())
                ?.subscribe(object : Observer<LiveDetailBean?> {
                    override fun onCompleted() {}
                    override fun onError(e: Throwable) {
                        dismissLoadingDialog()
                        mView?.showError(e.toString())
                    }

                    override fun onNext(t: LiveDetailBean?) {
                        dismissLoadingDialog()
                        if (t?.data != null && t.code == 200) {


                        } else {
                            mView?.showError(context.getString(R.string.connectFailure))
                        }
                    }
                })
        )
    }
}